<template>
  <div>
    <ProductInfo :data="productInfo" :parentCategoryList="parentCategoryList" :categoryList="categoryList" :readonly="true">
        商品详情
    </ProductInfo>
  </div>
</template>

<script>
import ProductInfo from "../../common/ProductInfo";
import { productInfo, category } from "../../../util/netWork";
export default {
  data: () => ({
    productInfo: {},
    parentCategoryList:[],
    categoryList:[],
  }),
  components: {
    ProductInfo
  },
  methods: {
    categoryHttp1() {
      category().then(res => {
        if (res.status == 0) {
          this.parentCategoryList = res.data;
        } else {
          alert(res.msg);
        }
      });
    },
    categoryHttp2() {
      var a = {
        categoryId: this.productInfo.categoryId
      };
      category(a).then(res => {
        if (res.status == 0) {
          this.categoryList = res.data;
        //   console.log(res.data);
        } else {
          alert(res.msg);
        }
      });
    }
  },
  mounted() {
    // console.log(this.$route.params.data.id)
    var data = {
      productId: this.$route.params.data.id
    };
    productInfo(data).then(res => {
      if (res.status == 0) {
        this.productInfo = res.data;
        // console.log(res.data)
        this.categoryHttp1();
        this.categoryHttp2();
      } else {
        alert(res.msg);
      }
    });
  }
};
</script>

<style lang="scss" scoped>
</style>